package controladores;

import java.io.*;

public class ManagerArchivo {

    public Object leer(String name) {
        File f = new File(name);
        FileInputStream fis = null;
        ObjectInputStream ois = null;
        Object o = null;
        try {
            if (f.exists()) {
                fis = new FileInputStream(f);
                ois = new ObjectInputStream(fis);
                o = ois.readObject();
            }
        } catch (Exception ex) {
            
        } finally {
            try {
                if (fis != null) {
                    fis.close();
                }
                if (ois != null) {
                    ois.close();
                }
            } catch (Exception ex) {
                
            }
        }
        return o;
    }

    public void escribir(Object o, String name) throws IOException {
        File f = new File(name);
        ObjectOutputStream oos = null;
        try {
            oos = new ObjectOutputStream(new FileOutputStream(f));
            oos.writeObject(o);
        } finally {
            if (oos != null) {
                oos.close();
            }
        }

    }
}
